<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Page</title>
    <style>
        #box{
            width: 100px;
            height: 100px;
        }
        .btn{
            margin: auto;
        }
        .not_click{
            cursor: not-allowed;
        }
        .click{
            background-color: pink;
            cursor: pointer;
        }
        
    </style>
</head>
<body>
    <div id="box">
        <p>1</p>
    </div>
    <button class="btn">1</button>
    <button class="btn">2</button>
    <button class="btn">3</button>
    <button class="btn">4</button>
    <button class="btn">5</button>
    <script>
        let obtn = document.getElementsByClassName('btn'),
            //obox = document.getElementsByClassName('box'),
            len = obtn.length;
        for (let index = 0; index < len; index++) {
            //鼠标经过（覆盖）事件
            obtn[index].onmouseover = function(){
                for (let j = 0; j < len; j++) {
                    //清除原先有的样式
                    obtn[j].classList.remove('not_click');
                    obtn[j].classList.remove('click');
                }
                obtn[index].classList.add("click");
                //鼠标点击事件
                obtn[index].onclick = function(){
                    changepage(index);
                }
            }          
        }
        //切换页
        function changepage(i){
            let text = '';
            text = i+1;
            box.innerHTML = text;
        }

    </script>
</body>
</html>